<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>文章管理</title>
<style type="text/css">
<!--
*{margin:0;padding:0;list-style:none;}
body,html{height:97%;}
body{background-color: #ffffff;}
#left_tree{float:left;width:175px;height:100%;border:1px solid #ccc;background:#ffffff;overflow:auto;padding:10px; }
#right_main{float:left;width:97%;height:auto !important;min-height:100%;border:1px solid #ccc;background:#ffffff;padding:10px;}

ul li{ vertical-align: middle; line-height: 20px;}
.ul_tree li{width:98%;min-width:175px;dispaly:inline;white-space:nowrap;font-size:13px;	font-family:'宋体';height:20px;cursor:pointer;}
.ul_tree li img{vertical-align: middle;}
.on_li{font-size:13px;font-family:'宋体';vertical-align:middle;	line-height:20px;height:20px;cursor:pointer;font-weight: bold;color:red;font-style: italic;}
.ul_tree_node li{width:auto !important;min-width:175px;dispaly:inline-block;display:-moz-inline-box; white-space:nowrap; font-size:13px;height:20px;cursor:pointer;}
.ul_tree_node li img{vertical-align: middle;margin-top:0px;}

#right_top{ border:0px solid #c1dcee;height:auto !important;min-height:30px;padding:5px;vertical-align:middle;line-height:30px;}


.table{border-collapse:collapse;border:none;}
.table td{border:solid #c1dcee 1px;  font-size:15px;padding:3px;}
.trHead td{text-align:center;height:22px;background-image: url('${rc.contextPath}/images/td_bg.png');background-repeat: repeat-x;}

.tr td{font-size:13px;text-align:center;}
.tr:hover{background-color: #D8F79D}

.tools{margin: 5px; font-style: normal; font-size: 14px; height:25px;}
.tools{text-decoration: none;height: 24px;margin: 0 5px 0 0;background: url('${rc.contextPath}/images/btnout_bg_left.gif') no-repeat left center;float: left;_display: inline;-moz-user-select:none;}
.tools img {margin: 2px 0px 4px 4px;_display: inline;float: left; border: 0px;}
.tools b {cursor:pointer;	white-space: nowrap;color: #666;font-weight: normal;height: 24px;padding:0 3px 0 3px;line-height: 24px;background: url('${rc.contextPath}/images/btnout_bg_right.gif') no-repeat right center;display:inline-block;+zoom: 1;+display: inline;}
.tools:hover {text-decoration: none;background: url('${rc.contextPath}/images/btnover_bg_left.gif') no-repeat left center;}
.tools:hover b {color: #147;background: url('${rc.contextPath}/images/btnover_bg_right.gif') no-repeat right center;}

.page_control{ padding:10px 5px;width:100%;height:auto !important;height:10px;}
.page_control a{ padding:0 5px; text-decoration:none;margin-right:5px;background-color:#CCC;color:#4164F1;}
.page_control a:hover{ text-decoration:none;margin-right:5px;background-color:#add2da;color:#fff;}
.page_control .on{ text-decoration:none; background-color: #136DA9;color:#fff;}
.f_l{ float:left; font-size:15px; color:#176193}
.f_r{ float:right;font-size:15px; color:#176193}

.select_web{width:100px;font-size:14px;color:#5E5E5E}
.input_text{width:100px;font-size:13px;background-color:#ffffff;padding:3px;border:1px solid #ccc;}

#div_li{color:#4D4D4D;font-size:15px;height:25px;vertical-align: middle;line-height:25px;}
#div_li:hover{background-color: #ccc;color:#ffffff;border:1px dashed #ccc;}

.order_img{float:left;cursor:pointer;margin-left:8px; }

.site_result{display: inline-block;width: 100%;height:28px;font-size:12px;font-weight:bold; vertical-align:middle;line-height:28px; border:1px solid #ccc; overflow: hidden;white-space: nowrap; text-overflow: ellipsis; cursor:pointer;}
.site_result:hover{background: #ccc;}
.panel_btn	{width:60px;height:20px;font-size:13px;text-align:center; vertical-align: middle;line-height:20px;cursor:pointer; }
.panel_btn1 {background: url('${rc.contextPath}/images/btn1.png')  no-repeat;color:#000000;float:left;}
.panel_btn2 {background: url('${rc.contextPath}/images/btn2.png')  no-repeat;color:#ffffff;float:left;}
.panel_box	{width:99%;min-height:40px;height:auto !important;border:1px solid #ccc;vertical-align: middle;line-height:40px;padding-left:15px;font-size:13px;background: #D5DEDB;}
.panel_box a{margin-top:5px;}
._loading	{background:#000000;opacity:0.8;position: absolute;z-index:220;width:100%;height:93%;margin:-48px 0px 0px -10px;display:none;}
.tip_show	{color:#ffffff;z-index:1220;position: relative;text-align:center;margin-top:100px;display:none;}
.filepath	{height:30px;vertical-align: middle;line-height:30px;font-size: 13px;font-weight: bold;color:#4c67ba;border-bottom: 1px solid #ccc;}
.fileslist	{height:380px;overflow:auto;overflow-x:hidden;}
.file		{height:30px;vertical-align: middle;line-height:30px;font-size: 13px;}
.delFold	{float:right;}
.prew		{float:right;margin-top:-30px;}
-->
</style>
</head>
<body>
<input type="hidden" id="check_state" value="${result}"/>
<table border="0" width="100%" height="100%">
	<tr>
		<td style="height:100%;width:15%" valign="top">
		<%-- 所有栏目区 --%>
		<div id="left_tree"></div>
		</td>
		<td style="height:100%" valign="top">
		<div id="right_main">
			<%-- 按钮区 --%>
			<div id="right_top">
			
				<c:if test="${result == 0}">
					<div id="panel_parent">
					<div onclick="btnPanelCtrl(this,'panel_index')"  class="panel_btn panel_btn1">首选项</div>
					<div onclick="btnPanelCtrl(this,'panel_check')" class="panel_btn panel_btn2">审核</div>
					<div onclick="btnPanelCtrl(this,'panel_query')" class="panel_btn panel_btn2">查询</div>
					<div onclick="btnPanelCtrl(this,'panel_link')" class="panel_btn panel_btn2">关联</div>
					<div onclick="btnPanelCtrl(this,'panel_expo')" class="panel_btn panel_btn2">导入/出</div>
					<div id="panel_clear" style="clear: both;"></div>
					</div>
					<div id="panel_index" class="panel_box">
						<span style="margin-right: 5px; font-style: normal; font-size: 14px; height:25px;float:left;" >
							选择站点：<select id="select_web" onchange="loadTcolunmSource(this,true)" class="select_web" style="width:120px;"></select>
							<input type="text" id="_siteName_web" onkeyup="extendArticle.addDivPanel(this,'loadTcolunmSource(this,false)')" onblur="extendArticle.delDivPanel()"  style="margin-left:-127px;font-size:14px; position: relative;width:100px;"/>
						</span>
						<a href="javascript:void(0)" onclick="newArticle()"  class="tools" ><img  src="${rc.contextPath }/images/icon002a2.gif"/><b>　新建　</b></a>
						
						<a href="javascript:void(0)" onclick="previewArticle()" class="tools" ><img  src="${rc.contextPath }/images/web.gif" /><b>　预览　</b></a>
						<div style="clear: both;"></div>
					</div>
					<div id="panel_check" class="panel_box" style="display:none;">
						<c:if test="${usermenu.freadonly == 'w' || usermenu.freadonly == 'wc'}">
							<a href="javascript:void(0)" onclick="editAr()" class="tools" ><img  src="${rc.contextPath }/images/icon002a4.gif" /><b>　编辑　</b></a>
							<a href="javascript:void(0)" onclick="updateArticleCheck(1)" class="tools" ><img  src="${rc.contextPath }/images/icon002a4.gif" /><b>取消通过</b></a>
							<a href="javascript:void(0)" onclick="updateArticleForDel()" class="tools" ><img  src="${rc.contextPath }/images/icon002a3.gif" /><b>　删除　</b></a>
							<a href="javascript:void(0)" onclick="delArticleFromTcol()" class="tools" ><img  src="${rc.contextPath }/images/icon002a3.gif" /><b>解除关联　</b></a>
						</c:if>
						<div style="clear: both;"></div>
					</div>
					<div id="panel_query" class="panel_box" style="display:none;">
					<%-- 条件查询 --%>
						<form id="articleByCid_form" method="post">
							<input type="hidden" name="start" id="start" value="0" />
							<input type="hidden" name="limit" id="limit" value="10" />
							<c:if test="${result == 0}">
								<!-- 高级搜索 -->
								<span style="float:left;">
										标题:<input type="text" id="aname"  class="input_text" />
										添加时间:<input type="text" id="startTime"  onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',realFullFmt:'%Date'})" class="Wdate" style="width:100px;"/>至
												<input type="text" id="endTime" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',realFullFmt:'%Date'})" class="Wdate" style="width:100px;"/>
										类型:<select id="fclassid"  class="select_web"></select>
										分类:<select id="ftypeid"   class="select_web"></select>
										创建人:<select id="addPersion"   class="select_web"></select>
								</span>		
									<a href="javascript:void(0)" onclick="queryArticleByArticleRequest()" class="tools" ><img  src="${rc.contextPath }/images/gif_45_090.gif" /><b>查询</b></a>
							</c:if>	
						</form>
						<div style="clear: both;"></div>
					</div>
					<div id="panel_link" class="panel_box" style="display:none;">
						<a href="javascript:void(0)" onclick="updateTemplate()" class="tools" ><img  src="${rc.contextPath }/images/icon002a4.gif" /><b>更改模板</b></a>
						<a href="javascript:void(0)" onclick="moveArticleTcol('${rc.contextPath}')"  class="tools" ><img  src="${rc.contextPath }/images/move.png" width="20px" height="20px"/><b>关联到栏目</b></a>
						<a href="javascript:void(0)" onclick="moveColummForSite('${rc.contextPath}');"  class="tools" ><img  src="${rc.contextPath }/images/move.png" width="20px" height="20px"/><b>关联栏目到网站</b></a>
						<a href="javascript:void(0)" onclick="cLink.loadSource(true);"  class="tools" ><img  src="${rc.contextPath }/images/icon002a15.gif" width="20px" height="20px"/><b>栏目关联网站列表</b></a>
						<a href="javascript:void(0)" onclick="associationTcolQuery('${rc.contextPath}')" class="tools" ><img  src="${rc.contextPath }/images/icon002a11.gif" /><b>已关联栏目</b></a>
						<a href="javascript:void(0)" onclick="queryTcolSource('freequery')" class="tools" ><img  src="${rc.contextPath }/images/icon002a15.gif" /><b>未关联的文章　</b></a>
						<a href="javascript:void(0)" onclick="copyClumn.loadClumn('${rc.contextPath}');" class="tools" ><img  src="${rc.contextPath }/images/icon002a13.gif" /><b>栏目复制　</b></a>
						<div style="clear: both;"></div>
					</div>
					<div id="panel_expo" class="panel_box" style="display:none;">
						<a href="javascript:void(0)" onclick="aritcleGenneration.export_article('select')" class="tools" ><img  src="${rc.contextPath }/images/import.gif" /><b>　导出　</b></a>
						<a href="javascript:void(0)" onclick="aritcleGenneration.export_article('all')" class="tools" ><img  src="${rc.contextPath }/images/import.gif" /><b>导出全部</b></a>
						<a href="javascript:void(0)" onclick="aritcleGenneration.import_article();" class="tools" ><img  src="${rc.contextPath }/images/export.gif" /><b>　导入　</b></a>
						<a href="javascript:void(0)" onclick="fileUpLoad.uploadDialog();" class="tools" ><img  src="${rc.contextPath }/images/tree/icon_up.gif" /><b>  上传　</b></a>
						<a href="javascript:void(0)" onclick="fileUpLoad.fileListDialog();" class="tools" ><img  src="${rc.contextPath }/images/tree/file.gif" /><b>文件列表</b></a>
						<div style="clear: both;"></div>
					</div>

				</c:if>
				<c:if test="${result == 2}">
					<span style="margin-right: 5px; font-style: normal; font-size: 14px; height:25px;float:left;" >
					查看：<select id="checkType" onchange="queryTcolSource(1);"><option value="2" selected="selected">未审核</option><option value="1">不通过</option></select></span>
					<a href="javascript:void(0)" onclick="editAr()" class="tools" ><img  src="${rc.contextPath }/images/icon002a4.gif" /><b>编辑</b></a>
					<a href="javascript:void(0)" onclick="updateArticleCheck(0)"  class="tools" ><img  src="${rc.contextPath }/images/icon002a2.gif"/><b>通过</b></a>
					<a href="javascript:void(0)" onclick="updateArticleCheck(1)" class="tools" ><img  src="${rc.contextPath }/images/icon002a4.gif" /><b>不通过</b></a>
					<a href="javascript:void(0)" onclick="previewArticle()" class="tools" ><img  src="${rc.contextPath }/images/web.gif" /><b>预览</b></a>
					<a href="javascript:void(0)" onclick="updateArticleForDel()" class="tools" ><img  src="${rc.contextPath }/images/icon002a3.gif" /><b>删除</b></a>
				</c:if>
				
			</div>
			 
			<font style="padding:2px;color:#225F88;font-size:16px;">文章列表</font>
			
			<table class="table" align="center" width="100%">
				<thead>
					<tr class="trHead">
						<td width="5%"><input type="checkbox" id="allCk" onclick="ckCheckbox(this)" /></td>
						<td width="5%">编号</td>
						<td width="25%">
						<c:if test="${result == 0}">
						<select id="order_type" style="float:left;" onchange="changeOrderType()">
							<option value="insertList">按添加顺序排序</option>
							<option value="orderList">自定义排序</option>
						</select>
						<span id="insertList_img">
						<img  class="order_img" onclick="order_source(this,'${rc.contextPath}')" title="升序/降序" src="${rc.contextPath }/images/up_list.gif">
						</span>
						<span id="orderList_img" style="display:none;">
						<img  class="order_img"  title="置顶" onclick="moveForTr.moveTopBo('dataGrid',0)" src="${rc.contextPath }/images/priority_1.gif">
						<img  class="order_img"  title="向上移动" onclick="moveForTr.moveUp('dataGrid')" src="${rc.contextPath }/images/priority_2.gif">
						<img  class="order_img"  title="向下移动" onclick="moveForTr.moveDown('dataGrid')" src="${rc.contextPath }/images/priority_3.gif">
						<img  class="order_img"  title="置尾" onclick="moveForTr.moveTopBo('dataGrid',1)" src="${rc.contextPath }/images/priority_4.gif">
						</span>
						</c:if>
						标题</td>
						<td width="10%">类型</td>
						<td width="10%">分类</td>
						<td width="10%">审核状态</td>
						<td width="10%">创建人</td>
						<td width="15%">创建时间</td>
						<td id="webName" style="display:none;width:10%" >网站</td>
					</tr>
				</thead>
				<tbody id="dataGrid">
				</tbody>
			</table>
			
				<div class="page_control">
					<span class="f_l" id="totalCount"></span>
					<span class="f_r" id ='pagePanel'></span>
				</div>
			
		</div>
		</td>
	</tr>
</table>
<!-- 播放串 -->
<div id="show_play_add" style="height:52px;;width:450px;position: absolute;display:none;">
<div style="width:11px;float:left;height:50px;padding-top:19px;"><img  src="${rc.contextPath }/images/rarrowleft.gif"></div>
<div style="border:3px solid #C9F0FE;width:430px;height:50px;float:left;background: #ffffff;">
	<span id="play_html" style="display:block;width:100%;font-size:14px;overflow:hidden;word-break:break-all;padding:5px;">播放地址：</span>
</div>	
<div style="clear: both;"></div>
</div>
<!-- web panner -->
<div id="_dPanel" style="width:160px;height:auto !important;min-height:50px;background: #ffffff;z-index: 811215;border:1px solid #ccc;position: absolute;">
</div>
<script type="text/javascript" src="${rc.contextPath }/js/jquery/jquery-1.8.2.js"></script>
<script type="text/javascript" src="${rc.contextPath }/js/jquery/jquery.form.js"></script>
<script type="text/javascript" src="${rc.contextPath }/js/jquery/jquery.blockUI.js" charset="utf-8"></script>
<script type="text/javascript" src="${rc.contextPath}/js/kindeditor-min.js" ></script>
<script type="text/javascript" src="${rc.contextPath }/js/datepicker/WdatePicker.js" charset="utf-8"></script>
<script type="text/javascript" src="${rc.contextPath }/js/article/article.js" ></script>
<script type="text/javascript" src="${rc.contextPath }/js/article/conf.js" ></script>
<script type="text/javascript" src="${rc.contextPath}/js/article/editArticle.js" ></script>
<script type="text/javascript" src="${rc.contextPath}/js/article/move.js" ></script>
<script type="text/javascript" src="${rc.contextPath}/js/article/colLink.js" ></script>
<script type="text/javascript" src="${rc.contextPath}/js/article/article.plugins.js" ></script>
<script type="text/javascript" src="${rc.contextPath}/js/page.js" ></script>

<script type="text/javascript">
$(document).ready(function(){
	loadWebsiteInfoSource();
	queryChange();
	loadAllUserArr();
});

var target = document.getElementById('show_play_add');
document.onclick = function(){
	show_play_add.style.display = "none";
};
target.onclick = function(){
	if(document.all){
		window.event.cancelBubble = true;
 	}else{
		event.stopPropagation(); 
	}
};


function loadWebsiteInfoSource(){
	$.ajax({
		url:'websiteinfoSource',
		type:'post',
		dataType:'json',
		success:function(data){
			var html = '<option value="" disabled="disabled" selected="selected">----站点列表----</option>',sHtml = '';
			$.each(data,function(i,u){
				html += '<option value="'+u.id+'">'+u.ftitle+'</option>';
				sHtml += '<span class="site_result" id="'+u.id+'">' +u.ftitle+ '</span>';
			});
			$("#select_web").html(html);
			$("#_dPanel").html(sHtml);
			$("#_dPanel").hide();
		},
		error:function(msg){
			$.growlUI('网站数据加载出错');
		}
	});
	
}
///加载所有栏目数据
function loadTcolunmSource(obj,isSelct){
	
	if(!isSelct)
		$("#_siteName_web").val(obj.innerHTML);
	else
		$("#_siteName_web").val(obj.options[obj.selectedIndex].text);
	
	_waiting._show();
	$.ajax({
		url:'tcolunmSource',
		type:'post',
		data:{'webid':isSelct?obj.value:obj.id,'check':$("#check_state").val(),'type':0},
		dataType:'json',
		success:function(data){
			_articleCount = 0 ;
			$("#left_tree").html($.fn.simpleTree(data,'${rc.contextPath}',false,isSelct?obj.options[obj.selectedIndex].text:obj.innerHTML,undefined,101));
			$("#website_ArticleCont101").html('('+_articleCount+')');
			_waiting._hide();
		},
		error:function(msg){
			$.growlUI('栏目加载出错');
			_waiting._hide();
		}
	});
}
///新建文章
function newArticle(){
	var webid = $("#select_web").val();
	//var feature="fullscreen=yes,toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,resizable=no";  
    window.open('editArticle_index?webId=' + webid +'&mid=${mid}','big'); 
}
//全选 反选
function ckCheckbox(obj){
	if(obj.checked){
		$("input[type='checkbox'][name='articleId']").attr('checked',true);
		
	}else{
		$("input[type='checkbox'][name='articleId']").attr('checked',false);
	}
	
	$("input[type='checkbox'][name='articleId']").each(function(){
		dblCkBox($(this).val());
	});
}
//编辑
function editAr(){
	var aid = $("input[type='checkbox'][name='articleId']:checked").val();
	var webid = $("#select_web").val();
	if(aid != undefined && aid != ''){
		var tcolid = '';
		if(liObj != null && liObj != undefined)
			tcolid = liObj.value;
		
		//var feature="fullscreen=yes,status=no,location=no,directories=no,menubar=no,scrollbars=yes,resizable=no";  
	    window.open('editArticle_index?aid='+aid+'&webId=' + webid+'&tcolId='+tcolid + '&mid=${mid}','big'); 
	}else{
		$.growlUI('请选中一篇文章');
	}
}
//预览
function previewArticle(){
	var aid = $("input[type='checkbox'][name='articleId']:checked").val();
	if(aid != undefined && aid != ''){
		window.open('${rc.contextPath}/site/preview?id='+aid + '&cid=' + liObj.value);
	}else{
		$.growlUI('请选中文章');
	}
}

function btnPanelCtrl(obj,id){
	 $("#panel_parent > div").each(function(){
		 if($(this).attr("id") != 'panel_clear'){
			 $(this).removeClass();
			 $(this).addClass('panel_btn panel_btn2');
		 }
	 });
	 $(obj).removeClass();
	 $(obj).addClass('panel_btn panel_btn1');
	 $(".panel_box").hide();
	 $("#" + id).show();
}
</script>
</body>
</html>